public class LoanCalculator {
    int a;
    int m;
    double y;
    double avgInt;
    double avgCap;
    public LoanCalculator(int a, int m, double y) {
        this.a = a;
        this.m = m;
        this.y = y;
    }
    public void avgCaption() {
        avgCap = (m + 1) * a * (y / 12) / 2;
    }
    public void avgInterest() {
        double n = Math.pow(1+(y/12),m);
        avgInt = m * a * (y/12) * n / (n-1) - a;
    }
    public void print() {
        System.out.println("等额本金:" + avgCap);
        System.out.println("等额本息:" + avgInt);
    }
}
